class ProcatesController < ApplicationController
  # GET /procates
  # GET /procates.xml
  layout "admin"
  before_filter :admin?
  cache_sweeper :link_sweeper,:only=>[:new,:create,:update]
  
  def index
    @procates = Procate.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @procates }
    end
  end

  # GET /procates/1
  # GET /procates/1.xml
  def show
    @procate = Procate.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @procate }
    end
  end

  # GET /procates/new
  # GET /procates/new.xml
  def new
    @procate = Procate.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @procate }
    end
  end

  # GET /procates/1/edit
  def edit
    @procate = Procate.find(params[:id])
  end

  # POST /procates
  # POST /procates.xml
  def create
    @procate = Procate.new(params[:procate])

    respond_to do |format|
      if @procate.save
        flash[:notice] = 'Procate was successfully created.'
        format.html { redirect_to(procates_path) }
        format.xml  { render :xml => @procate, :status => :created, :location => @procate }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @procate.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /procates/1
  # PUT /procates/1.xml
  def update
    @procate = Procate.find(params[:id])

    respond_to do |format|
      if @procate.update_attributes(params[:procate])
        flash[:notice] = 'Procate was successfully updated.'
        format.html { redirect_to(procates_path) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @procate.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /procates/1
  # DELETE /procates/1.xml
  def destroy
    @procate = Procate.find(params[:id])
    @procate.destroy

    respond_to do |format|
      format.html { redirect_to(procates_url) }
      format.xml  { head :ok }
    end
  end
end
